<?xml version="1.0" encoding="UTF-8"?>
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui"
	template="/templates/template.xhtml">


	<ui:define name="body">
		<h:form id="formId" prependId="false">
			<p:fieldset legend="#{participanteBean.qualifiedName}" id="fieldPrincipal">
				<h:panelGrid columns="5" id="panelCadastro" border="0" columnClasses="coluna15,coluna30,coluna5,coluna20,coluna40"
					width="100%">

					<h:outputLabel value="Área Atuação" styleClass="icoObrigatorio" />
					<p:autoComplete dropdown="true" queryDelay="500" value="#{participanteBean.areaAtuacao}" minQueryLength="2"
						id="area" size="40" completeMethod="#{participanteBean.completeArea}" forceSelection="true" var="lista"
						itemLabel="#{lista.descricao}" itemValue="#{lista.id}" converter="areaConverter">
					</p:autoComplete>
					<p:commandLink title="Adicionar Área" style="padding:5px !important;" process="@this" onclick="popArea.show();">
						<h:graphicImage library="design/imagem" name="icone-adicionar.png" />
					</p:commandLink>
					<p:message for="area" />
					<h:outputText value=" " />
				</h:panelGrid>

				<h:panelGrid columns="4" id="panelCadastro2" border="0" columnClasses="coluna15,coluna30,coluna20,coluna45"
					width="100%">

					<h:outputLabel value="Nome:" styleClass="icoObrigatorio" />
					<p:inputText value="#{participanteBean.model.nome}" id="nome" size="50" maxlength="255" />
					<p:message for="nome" />
					<h:outputText value=" " />


					<h:outputLabel value="CPF:" />
					<p:inputMask mask="999.999.999-99" value="#{participanteBean.model.cpf}" id="cpf" size="50" maxlength="255" />
					<p:message for="cpf" />
					<h:outputText value=" " />

					<h:outputLabel value="Email:" styleClass="icoObrigatorio" />
					<p:inputText value="#{participanteBean.model.email}" id="email" size="50" maxlength="255" />
					<p:message for="email" />
					<h:outputText value=" " />

					<h:outputLabel value="UF(Residencial):" styleClass="icoObrigatorio" />
					<p:selectOneMenu id="uf" value="#{participanteBean.idUf}" effect="fade" style="width:300px;">
						<f:selectItem itemLabel="Selecione" itemValue="" />
						<f:selectItems value="#{participanteBean.ufs}" />
						<p:ajax update="municipio" process="@this" event="change" listener="#{participanteBean.changeUF}" />
					</p:selectOneMenu>
					<p:message for="uf" />
					<h:outputText value=" " />

					<h:outputText value="Município(Residencial):" styleClass="icoObrigatorio" />
					<p:selectOneMenu id="municipio" value="#{participanteBean.idMunicipio}" effect="fade" style="width:300px;">
						<f:selectItem itemLabel="Selecione" itemValue="" />
						<f:selectItems value="#{participanteBean.municipios}" />
					</p:selectOneMenu>
					<p:message for="municipio" />
					<h:outputText value=" " />

					<h:outputLabel value="Bairro:" />
					<p:inputText value="#{participanteBean.model.bairro}" id="bairro" size="50" maxlength="255" />
					<p:message for="bairro" />
					<h:outputText value=" " />

					<h:outputLabel value="Logradouro:" />
					<p:inputText value="#{participanteBean.model.logradouro}" id="logradouro" size="50" maxlength="255" />
					<p:message for="logradouro" />
					<h:outputText value=" " />

					<h:outputLabel value="Complemento:" />
					<p:inputText value="#{participanteBean.model.complemento}" id="complemento" size="50" maxlength="255" />
					<p:message for="complemento" />
					<h:outputText value=" " />

					<h:outputLabel value="Número:" />
					<p:inputText value="#{participanteBean.model.numero}" id="num" size="50" maxlength="255" />
					<p:message for="num" />
					<h:outputText value=" " />

					<h:outputLabel value="Cep:" />
					<p:inputMask mask="99999-999" value="#{participanteBean.model.cep}" id="cep" size="20" maxlength="255" />
					<p:message for="cep" />
					<h:outputText value=" " />



					<h:outputLabel value="Receber informações da fapdf?" styleClass="icoObrigatorio" />
					<p:selectOneRadio id="options" value="#{participanteBean.model.flgReceberInfo}">
						<f:selectItem itemLabel="Sim" itemValue="true" />
						<f:selectItem itemLabel="Não" itemValue="false" />
					</p:selectOneRadio>
					<p:message for="options" />
					<h:outputText value=" " />
				</h:panelGrid>
				<br />

				<p:toolbar>
					<p:toolbarGroup align="left">
						<p:commandButton rendered="#{p:ifGranted('ROLE_USER')}" value="Salvar" ajax="true" process="@form" update="@form"
							action="#{participanteBean.save}" />
						<p:commandButton value="Limpar" immediate="true" ajax="false" action="participante.jsf" />
					</p:toolbarGroup>
				</p:toolbar>
				<br />
				<p:panel header="Relatório(s)" width="100%" id="panelPdf">
					<h:commandLink>
						<h:graphicImage library="design/imagem" name="excel.png" />
						<p:dataExporter type="xls" target="listaParti" fileName="participantes" />
					</h:commandLink>

					<h:commandLink>
						<h:graphicImage library="design/imagem" name="pdf.png" />
						<p:dataExporter excludeColumns="4,5,7,8" type="pdf" encoding="ISO-8859-1" target="listaParti"
							fileName="participantes" preProcessor="#{participanteBean.preProcessPDF}" />
					</h:commandLink>
				</p:panel>

				<br />
				<p:dataTable paginatorPosition="bottom" var="lista" id="listaParti" emptyMessage="#{participanteBean.emptyMessage}"
					update="listaParti" rowsPerPageTemplate="#{participanteBean.paginacao}" styleClass="coluna100"
					value="#{participanteBean.lazyDataModel}" paginator="true" rows="10"
					rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'linhaImpar' : 'linhaPar'}" rowIndexVar="rowIx">

					<p:column headerText="Área" sortBy="#{lista.areaAtuacao.descricao}" filterBy="#{lista.areaAtuacao.descricao}"
						style="width:15%;font-size: 12px;">
						<f:facet name="header">
							<h:outputText value="Área" />
						</f:facet>
						<h:outputLabel value="#{lista.areaAtuacao.descricao}" />
					</p:column>
					<p:column headerText="Nome" sortBy="#{lista.nome}" filterBy="#{lista.nome}" style="width:15%;font-size: 12px;">
						<f:facet name="header">
							<h:outputText value="Nome" />
						</f:facet>
						<h:outputLabel value="#{lista.nome}" />
					</p:column>
					<p:column headerText="CPF" sortBy="#{lista.cpf}" filterBy="#{lista.cpf}" style="width:10%;font-size: 12px;">
						<f:facet name="header">
							<h:outputText value="CPF" />
						</f:facet>
						<h:outputLabel value="#{lista.cpfFormat}" />
					</p:column>
					<p:column headerText="Email" sortBy="#{lista.email}" filterBy="#{lista.email}" style="width:15%;font-size: 12px;">
						<f:facet name="header">
							<h:outputText value="Email" />
						</f:facet>
						<h:outputLabel value="#{lista.email}" />
					</p:column>
					<p:column headerText="UF" sortBy="#{lista.municipio.uf.sigla}" filterBy="#{lista.municipio.uf.sigla}"
						style="width:5%;font-size: 12px;">
						<f:facet name="header">
							<h:outputText value="UF" />
						</f:facet>
						<h:outputLabel value="#{lista.municipio.uf.sigla}" />
					</p:column>
					<p:column headerText="Município" sortBy="#{lista.municipio.descricao}" filterBy="#{lista.municipio.descricao}"
						style="width:15%;font-size: 12px;">
						<f:facet name="header">
							<h:outputText value="Município" />
						</f:facet>
						<h:outputLabel value="#{lista.municipio.descricao}" />
					</p:column>
					<p:column headerText="Receber Inf da fapdf?" sortBy="#{lista.flgReceberInfo}" style="width:15%;font-size: 12px;">
						<f:facet name="header">
							<h:outputText value="Receber Inf da fapdf?" />
						</f:facet>
						<h:outputLabel value="#{lista.flgRecenerInforFormat}" />
					</p:column>
					<p:column headerText="Ações" style="width:10%;text-align:center;font-size: 12px;">
						<p:commandLink title="Editar" style="padding:5px !important;" update=":formId:fieldPrincipal" process="@this"
							action="#{participanteBean.load}">
							<h:graphicImage library="design/imagem" name="icone-editar.png" />
							<f:setPropertyActionListener target="#{participanteBean.model}" value="#{lista}" />
						</p:commandLink>
						<p:commandLink title="Excluir" process="@this" oncomplete="confirmation.show()">
							<h:graphicImage library="design/imagem" name="icone-excluir.png" />
							<f:setPropertyActionListener target="#{participanteBean.model}" value="#{lista}" />
						</p:commandLink>
					</p:column>

				</p:dataTable>
				<p:confirmDialog appendToBody="true" message="Confirma a Exclusão" header="Exclusão" severity="alert"
					widgetVar="confirmation">
					<h:panelGrid columns="2">
						<p:commandButton value="Sim" update="listaParti,panelPdf" oncomplete="confirmation.hide()"
							actionListener="#{participanteBean.delete}" immediate="true" />
						<p:commandButton value="Não" onclick="confirmation.hide()" />
					</h:panelGrid>
				</p:confirmDialog>
			</p:fieldset>

			<p:dialog position="center" appendToBody="false" widgetVar="popArea" header="Área Atuação" width="550" height="500">
				<p:fieldset id="fieldPrincipalArea">
					<h:panelGrid columns="4" id="panelCadastroArea" border="1" columnClasses="coluna15,coluna30,coluna20,coluna45"
						width="100%">
						<h:outputLabel value="Descrição:" styleClass="icoObrigatorio" />
						<p:inputText value="#{areaAtuacaoBean.model.descricao}" id="nomeArea" size="50" maxlength="255" />
						<p:message for="nome" />
						<h:outputText value=" " />
					</h:panelGrid>
					<br />

					<p:toolbar>
						<p:toolbarGroup align="left">
							<p:commandButton value="Salvar" ajax="true" process="fieldPrincipalArea" update="fieldPrincipalArea"
								action="#{areaAtuacaoBean.save}" />
							<p:commandButton value="Fechar" onclick="popArea.hide()" />
						</p:toolbarGroup>
					</p:toolbar>
					<br />
					<p:dataTable paginatorPosition="bottom" var="lista" id="lista" emptyMessage="#{areaAtuacaoBean.emptyMessage}"
						update="lista" styleClass="coluna100" value="#{areaAtuacaoBean.lazyDataModel}" paginator="true" rows="5"
						rowStyleClass="#{empty rowIx or rowIx mod 2 ne 0 ? 'linhaImpar' : 'linhaPar'}" rowIndexVar="rowIx">
						<p:column headerText="Descrição" sortBy="#{lista.descricao}" filterBy="#{lista.descricao}" style="width:80%">
							<h:outputLabel value="#{lista.descricao}" />
						</p:column>
					</p:dataTable>
				</p:fieldset>


			</p:dialog>
		</h:form>
	</ui:define>
</ui:composition>